
#include "SDL_config.h"

#ifdef __ANDROID__

/* Include the SDL main definition header */
#include "SDL_main.h"

/*******************************************************************************
                 Functions called by JNI
*******************************************************************************/
#include <jni.h>

// Called before SDL_main() to initialize JNI bindings in SDL library
extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls);

// Library init
extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    return JNI_VERSION_1_4;
}

// Start up the SDL app
extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
		jstring ip,jstring pass)
{
    /* This interface could expand with ABI negotiation, calbacks, etc. */
    SDL_Android_Init(env, cls);

       // str = (*env)->GetStringUTFChars(env, prompt, 0);//调c写法
      //  str = env->GetStringUTFChars(prompt, 0);//c++写法
    /* Run the application code! */
    const char* strip = env->GetStringUTFChars(ip, 0);
    const char* strpass = env->GetStringUTFChars(pass, 0);

    int status;
    char *argv[4];
    argv[0] = strdup("SDL_app");
    argv[1] = "-h\0";
    argv[2] = (char *)strip;
    argv[3] = (char *)strpass;
    status = SDL_main(4, argv);

    /* We exit here for consistency with other platforms. */
    exit(status);
}

#endif /* __ANDROID__ */

/* vi: set ts=4 sw=4 expandtab: */
